/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package org.taobao.ibatiside.model.configv3.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.taobao.ibatiside.model.configv3.Configv3Package;
import org.taobao.ibatiside.model.configv3.DataSourceType;
import org.taobao.ibatiside.model.configv3.EnvironmentType;
import org.taobao.ibatiside.model.configv3.TransactionManagerType;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Environment Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.taobao.ibatiside.model.configv3.impl.EnvironmentTypeImpl#getTransactionManager <em>Transaction Manager</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.configv3.impl.EnvironmentTypeImpl#getDataSource <em>Data Source</em>}</li>
 *   <li>{@link org.taobao.ibatiside.model.configv3.impl.EnvironmentTypeImpl#getId <em>Id</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class EnvironmentTypeImpl extends EObjectImpl implements EnvironmentType {
	/**
	 * The cached value of the '{@link #getTransactionManager() <em>Transaction Manager</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getTransactionManager()
	 * @generated
	 * @ordered
	 */
	protected TransactionManagerType transactionManager;

	/**
	 * The cached value of the '{@link #getDataSource() <em>Data Source</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDataSource()
	 * @generated
	 * @ordered
	 */
	protected DataSourceType dataSource;

	/**
	 * The default value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected static final String ID_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getId() <em>Id</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getId()
	 * @generated
	 * @ordered
	 */
	protected String id = ID_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EnvironmentTypeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Configv3Package.Literals.ENVIRONMENT_TYPE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TransactionManagerType getTransactionManager() {
		return transactionManager;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetTransactionManager(TransactionManagerType newTransactionManager, NotificationChain msgs) {
		TransactionManagerType oldTransactionManager = transactionManager;
		transactionManager = newTransactionManager;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Configv3Package.ENVIRONMENT_TYPE__TRANSACTION_MANAGER, oldTransactionManager, newTransactionManager);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setTransactionManager(TransactionManagerType newTransactionManager) {
		if (newTransactionManager != transactionManager) {
			NotificationChain msgs = null;
			if (transactionManager != null)
				msgs = ((InternalEObject)transactionManager).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Configv3Package.ENVIRONMENT_TYPE__TRANSACTION_MANAGER, null, msgs);
			if (newTransactionManager != null)
				msgs = ((InternalEObject)newTransactionManager).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Configv3Package.ENVIRONMENT_TYPE__TRANSACTION_MANAGER, null, msgs);
			msgs = basicSetTransactionManager(newTransactionManager, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Configv3Package.ENVIRONMENT_TYPE__TRANSACTION_MANAGER, newTransactionManager, newTransactionManager));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public DataSourceType getDataSource() {
		return dataSource;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetDataSource(DataSourceType newDataSource, NotificationChain msgs) {
		DataSourceType oldDataSource = dataSource;
		dataSource = newDataSource;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Configv3Package.ENVIRONMENT_TYPE__DATA_SOURCE, oldDataSource, newDataSource);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDataSource(DataSourceType newDataSource) {
		if (newDataSource != dataSource) {
			NotificationChain msgs = null;
			if (dataSource != null)
				msgs = ((InternalEObject)dataSource).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Configv3Package.ENVIRONMENT_TYPE__DATA_SOURCE, null, msgs);
			if (newDataSource != null)
				msgs = ((InternalEObject)newDataSource).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Configv3Package.ENVIRONMENT_TYPE__DATA_SOURCE, null, msgs);
			msgs = basicSetDataSource(newDataSource, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Configv3Package.ENVIRONMENT_TYPE__DATA_SOURCE, newDataSource, newDataSource));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getId() {
		return id;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setId(String newId) {
		String oldId = id;
		id = newId;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, Configv3Package.ENVIRONMENT_TYPE__ID, oldId, id));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case Configv3Package.ENVIRONMENT_TYPE__TRANSACTION_MANAGER:
				return basicSetTransactionManager(null, msgs);
			case Configv3Package.ENVIRONMENT_TYPE__DATA_SOURCE:
				return basicSetDataSource(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case Configv3Package.ENVIRONMENT_TYPE__TRANSACTION_MANAGER:
				return getTransactionManager();
			case Configv3Package.ENVIRONMENT_TYPE__DATA_SOURCE:
				return getDataSource();
			case Configv3Package.ENVIRONMENT_TYPE__ID:
				return getId();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case Configv3Package.ENVIRONMENT_TYPE__TRANSACTION_MANAGER:
				setTransactionManager((TransactionManagerType)newValue);
				return;
			case Configv3Package.ENVIRONMENT_TYPE__DATA_SOURCE:
				setDataSource((DataSourceType)newValue);
				return;
			case Configv3Package.ENVIRONMENT_TYPE__ID:
				setId((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case Configv3Package.ENVIRONMENT_TYPE__TRANSACTION_MANAGER:
				setTransactionManager((TransactionManagerType)null);
				return;
			case Configv3Package.ENVIRONMENT_TYPE__DATA_SOURCE:
				setDataSource((DataSourceType)null);
				return;
			case Configv3Package.ENVIRONMENT_TYPE__ID:
				setId(ID_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case Configv3Package.ENVIRONMENT_TYPE__TRANSACTION_MANAGER:
				return transactionManager != null;
			case Configv3Package.ENVIRONMENT_TYPE__DATA_SOURCE:
				return dataSource != null;
			case Configv3Package.ENVIRONMENT_TYPE__ID:
				return ID_EDEFAULT == null ? id != null : !ID_EDEFAULT.equals(id);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (id: ");
		result.append(id);
		result.append(')');
		return result.toString();
	}

} //EnvironmentTypeImpl
